import Vue from '@/main.js';



export  function insertDepartment(depName, description, pid, pids, unitType, unitId) {
  var path = "/auth/department/insertDepartment";
  return Vue.$http.post(path, {
      name: depName,
      description: description,
      pid: pid,
      pids: pids,
      unitType: unitType,
      unitId: unitId
    })
    .then((res) => {
        return res;
    })
    .catch(function (error) {
      console.error(error);
    });
}


export  function updateDeparement(params) {
  var path = "/auth/department/updateDepartment";
  return Vue.$http.post(path, params)
    .then((res) => {
        return res;
    })
    .catch(function (error) {
      console.error(error);
    });
}


export  function getDepartmentList(depName, pageNum ,pageSize, unitType, unitId) {
  var path = "/auth/department/getDepartmentList";
  return Vue.$http.post(path, {
      name: depName,
      pageNum: pageNum,
      pageSize: pageSize,
      unitType: unitType,
      unitId: unitId
    })
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}


export  function getFatherDepList(unitType, unitId,departmentId) {
  var path = "/auth/department/getFatherDepartmentList";
  return Vue.$http.post(path, {
    unitType: unitType,
    unitId: unitId,
    departmentId:departmentId,
  })
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}


export  function getDepInfoById(id) {
  var path = "/auth/department/getDepartmentDetail?id="+id;
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export  function deleteDepartmentById(depId) {
  var path = "/auth/department/deleteDepartment?id="+depId;
  return Vue.$http.get(path)
    .then((res) => {
        return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export  function getUserListByDepId(depId) {
  var path = "/auth/user/getUserListByDepId?depId="+depId;
  return Vue.$http.get(path)
    .then((res) => {
        return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}